Arrow keys / Click to navigate

Module 9: Securing Data

Advanced Architecting on AWS

KMS โ€ข CloudHSM โ€ข Envelope Encryption โ€ข ACM โ€ข Secrets Manager

๐ŸŽฏ Module Objectives

๐Ÿ”‘ AWS KMS Key Types

Key TypeManagementRotationUse Case
AWS Owned KeysAWS manages entirelyVariesDefault encryption (S3 SSE-S3)
AWS Managed KeysAWS creates per service (aws/s3, aws/ebs)Auto (yearly)Simple encryption without custom policy
Customer Managed Keys (CMK)You create, manage policiesConfigurable (90-2560 days)Cross-account, custom policies, auditing
Imported Key MaterialYou provide key materialManual onlyCompliance requiring external key origin
Decision guide: Need cross-account access or custom key policies? โ†’ Customer Managed Key. Simple encryption with no special requirements? โ†’ AWS Managed Key.

๐Ÿ“จ Envelope Encryption

Analogy: Envelope encryption is like a safe (KMS) that stores the key to your filing cabinet (data key). You use the filing cabinet key locally to lock/unlock documents. Only the cabinet key goes back to the safe.

๐Ÿฆ AWS CloudHSM

FeatureKMSCloudHSM
ManagementMulti-tenant, AWS-managedSingle-tenant, customer-managed
HSM TypeFIPS 140-2 Level 3FIPS 140-2 Level 3
Key accessAWS has administrative accessOnly you have key access (AWS cannot recover)
IntegrationNative AWS service integrationPKCS#11, JCE, OpenSSL, Microsoft CNG
Use caseMost encryption needsRegulatory requirements, Oracle TDE, SSL offload
PricingPer-API call + per-key/month~$1.50/hr per HSM (minimum 2 for HA)

๐Ÿ“œ ACM & Secrets Manager

AWS Certificate Manager

Free public SSL/TLS certificates. Auto-renewal. Integrates with ALB, CloudFront, API Gateway. Private CA available.

Secrets Manager

Store & rotate secrets (DB creds, API keys). Lambda rotation function. Cross-account sharing. Automatic rotation (30/60/90 days).

๐Ÿ” Encryption at Rest Summary

ServiceEncryption MethodKey Options
S3SSE-S3, SSE-KMS, SSE-C, client-sideBucket keys reduce KMS costs
EBSAES-256 (default encryption available)AWS managed or CMK
RDSAES-256 at volume levelMust enable at creation (immutable)
DynamoDBAES-256 (always encrypted)AWS owned, AWS managed, or CMK
EFSAES-256Must enable at creation

๐Ÿ’ป Demo: KMS Key Management

# Create a CMK
aws kms create-key --description "Production encryption key" \
  --key-usage ENCRYPT_DECRYPT --key-spec SYMMETRIC_DEFAULT

# Generate a data key (envelope encryption)
aws kms generate-data-key --key-id alias/prod-key \
  --key-spec AES_256

# Enable automatic rotation
aws kms enable-key-rotation --key-id alias/prod-key \
  --rotation-period-in-days 90

# Grant cross-account access
aws kms create-grant --key-id alias/prod-key \
  --grantee-principal arn:aws:iam::222233334444:role/AppRole \
  --operations Decrypt GenerateDataKey

๐Ÿงช Knowledge Check

Q1: An application encrypts files larger than 100MB before storing in S3. Which approach should it use?

A) Call KMS Encrypt API directly   B) Envelope encryption with GenerateDataKey   C) CloudHSM only   D) Client-side encryption with AES library

B) Envelope encryption with GenerateDataKey โ€” KMS can only encrypt 4KB directly. For large data, generate a data key via KMS, use it locally to encrypt the file, then store the encrypted data key alongside the encrypted file.

Q2: A company's compliance requires that AWS cannot access their encryption keys under any circumstances. What should they use?

A) AWS Managed KMS key   B) Customer Managed KMS key   C) CloudHSM   D) SSE-S3

C) CloudHSM โ€” CloudHSM provides single-tenant HSMs where only the customer has access to key material. AWS cannot recover or access keys in CloudHSM. KMS (even CMK) still has AWS administrative access to the infrastructure.

๐Ÿ“ Module 9 Summary

KMS

AWS owned/managed/customer keys. Envelope encryption for large data. Cross-account grants. Key rotation.

CloudHSM

Single-tenant. Customer-only key access. PKCS#11. Oracle TDE, SSL offload. ~$1.50/hr/HSM.

ACM & Secrets

Free public certs with auto-renewal. Secrets Manager for credential rotation. Lambda-based rotation.

Encryption at Rest

S3: SSE-S3/KMS/C. EBS: default encryption. RDS: enable at creation. DynamoDB: always encrypted.

Click anywhere to close